package cn.xuewei.security;

import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.math.BigDecimal;
import java.util.Collection;

//因为父类中有构造方法 此时添加@Data会让当前类添加构造方法,此方法可能会和父类的冲突所以报错

/**
 * 自定义Security认证用户类
 */
@Getter
public class CustomUserDetails extends User {
    /**
     * 用户id
     */
    private Long userid;
    /**
     * 用户昵称
     */
    private String nickname;
    /**
     * 头像
     */
    private String imgUrl;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 电话
     */
    private String mobile;
    /**
     * 是否为管理员
     */
    private Integer isAdmin;

    /**
     * 用户余额
     */
    private BigDecimal balance;


    public CustomUserDetails(BigDecimal balance,Integer isAdmin,Long userid,String nickname,
                             String imgUrl,String email,String mobile,
                             String username, String password, Collection<? extends GrantedAuthority> authorities) {
        super(username, password, authorities);
        this.userid = userid;
        this.nickname = nickname;
        this.imgUrl = imgUrl;
        this.email = email;
        this.mobile = mobile;
        this.isAdmin = isAdmin;
        this.balance = balance;
    }
}
